export default {
    data() {
        return {}
    },
    methods: {
        getFileType(id, code) {
            code = code.toLowerCase();
            let imageType = [
                "bmp",
                "jpg",
                "jpeg",
                "png",
                "svg",
                "gif",
                "psd",
                "webp",
            ];
            let videoType = [
                "mp4",
                "avi",
                "m4v",
                "3gp",
                "mov",
                "flv",
                "wmv",
                "rm",
                "rmvb",
                "asf",
                "asx",
                "mpg",
                "mpeg",
            ];

            if (imageType.indexOf(code) > -1) {
                if(id.indexOf("https:")> -1){
                    return {
                        src: id,
                        type: 'image'
                    }
                }else {
                    return {
                        src: `${process.env.VUE_APP_FILE_BASE_URL}/api/common/file/show/whdn/${id}`,
                        type: "image",
                    };
                }
            } else if (videoType.indexOf(code) > -1) {
                return {
                    src: `${process.env.VUE_APP_FILE_BASE_URL}/api/common/file/show/whdn/7e0bb99fce9b4e2381fbf945d951fc28`,
                    type: "video",
                };
            } else {
                return {
                    src: require("@/assets/img/icon-file.png"),
                    type: "other",
                };
            }
        },
    }
}